﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

using Kannon.Core;

namespace Kannon.Middleware
{
    public class BasicAuthenticationMiddleware : KannonMiddleware
    {
        public override KannonResponse Handle(KannonRequest request)
        {
            if(request.Headers["Authorization"] == null) 
                return new KannonResponse(HttpStatusCode.Unauthorized) {
                    Headers = { { HttpResponseHeader.WwwAuthenticate, "Basic realm=\"Secure Area\"" } } };

            return Application.Handle(request);
        }
    }
}
